home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Very Best of Atari Inside
/
The Very Best of Atari Inside 1.iso
/
mint
/
mntlib43
/
mntlib
/
ltoa.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-28
|
823b
|
53 lines
#include <string.h>
#include "lib.h"
#ifdef __STRICT_ANSI__
# ifdef __STDC__
char * strrev(char *);
# else
extern char * strrev();
# endif
#endif
char _numstr[] = "0123456789ABCDEF";
char *_ultoa(n, buffer, radix)
register unsigned long n;
register char *buffer;
register int radix;
{
register char *p = buffer;
do
{
*p++ = _numstr[n % radix]; /* grab each digit */
}
while((n /= radix) > 0);
*p = '\0';
return(strrev(buffer)); /* reverse and return it */
}
char *_ltoa(n, buffer, radix)
register long n;
register char *buffer;
int radix;
{
register char *p = buffer;
if (n < 0)
{
*p++ = '-';
n = -n;
}
_ultoa(n, p, radix);
return(buffer);
}
char *_itoa(n, buffer, radix)
int n;
char *buffer;
int radix;
{
return(_ltoa(((long) n), buffer, radix));
}